#ifndef ANALYZER_ALGORITHM_FACE_DETECTION_H
#define ANALYZER_ALGORITHM_FACE_DETECTION_H

#include <string>
#include <vector>
#include <mutex>
#include "Algorithm.h"

namespace AVSAnalyzer 
{
	class Config;
	class AlgorithmConfig;

	// libfacedetection 人脸检测引擎类
	class FaceDetectionEngine
	{
	public:
		explicit FaceDetectionEngine(const AlgorithmConfig& algorithmConfig);
		~FaceDetectionEngine();
	public:
		bool runInference(cv::Mat& image, std::vector<DetectObject>& detects);    // 执行人脸检测推理

	private:
		const AlgorithmConfig& mAlgorithmConfig;          // 算法配置引用
		float mScoreThreshold;                           // 置信度阈值
		void* mFaceDetector;                            // libfacedetection 检测器句柄
	};

	// 人脸检测算法实现类
	class AlgorithmFaceDetection : public Algorithm
	{
	public:
		AlgorithmFaceDetection(const AlgorithmConfig& algorithmConfig);
		virtual ~AlgorithmFaceDetection();
		virtual bool objectDetect(cv::Mat& image, std::vector<DetectObject>& detects) override;
	private:
		std::mutex mMtx;                                // 互斥锁，保证线程安全
		FaceDetectionEngine* mEngine;                   // 检测引擎指针
	};
}

#endif //ANALYZER_ALGORITHM_FACE_DETECTION_H

